
#ifndef _QUEUE_H_
#define _QUEUE_H_

#include "singlelink.h"

	/* Class for a queue data structure. Here, elements are added
	   and removed in the FIFO sequence. */

template <class e>
class Queue :  public SingleLink<e>
{
	public:
		Queue ();

		void Enqueue (e elem);
			// Enqueue an element in the queue
		e Dequeue();
			// Remove an element from the queue
		bool IsEmpty() { return head ==  NULL; }
			// Test if the queue is empty or not
};

template <class e>
Queue<e> :: Queue () : SingleLink<e>()
{
}

template <class e>
void Queue<e> :: Enqueue(e elem)
{
	// Insertion is done at the head as would require
	// of a queue and so we can just call that function
	SingleLink<e>::Insert (elem);
}

template <class e>
e Queue<e> :: Dequeue()
{
	// Remove the head if the head is not NULL
	if (head == NULL)
		return NULL;
	else
	{
		e temp = head->Element();
		head = head -> next();
		return temp;
	}
}

#endif